<?php

/*
	[MMOCom] (C)2008 MMOCom Inc.
	This is MMOCom software framework of PHP5

	$Id: index.php 12117 2009-01-01 00:00:00Z william $
*/

//error_reporting(0);
$memory_start = memory_get_usage();
$time_start = microtime(true);


define('ROOT_DIR', dirname(__FILE__).DIRECTORY_SEPARATOR);
define('ROOT_URL', strtolower(substr($_SERVER['SERVER_PROTOCOL'], 0, strpos($_SERVER['SERVER_PROTOCOL'], '/'))).'://'.$_SERVER['HTTP_HOST'].substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/')));

define('DATA_DIR', ROOT_DIR.'data'.DIRECTORY_SEPARATOR);
define('DATA_URL', ROOT_URL.'/data');

if(!@include DATA_DIR.'config.inc.php') {
	exit('The file <b>data/config.inc.php</b> does not exist');
}

require_once ROOT_DIR.'common.php';

require_once ROOT_DIR.'library'.DIRECTORY_SEPARATOR.'base.php';

$c = get_vars('c', 'index');
$a = get_vars('a', 'index');

$arr_c = array('index', 'test');

if (in_array($c, $arr_c)) {
	require_once ROOT_DIR . 'controls' . DIRECTORY_SEPARATOR . ucfirst($c) . "Controller.php";
	$control = new Control();
	//don't access private methods
	$action = 'on' . ucfirst($a);
	if (method_exists($control, $action) && $action{0} != '_') {
		$control->$action();
	} elseif (method_exists($control, '_call')) {
		$control->_call($action, '');
	} else {
		exit('Action not found!');
	}
} else {
	exit('Control not found!');
}





$time_end = microtime(true);
$memory_end = memory_get_usage();
$program_execute_time = $time_end - $time_start;
$program_execute_memory = $memory_end - $memory_start;
$program_execute_time = sprintf("%.5f", $program_execute_time);

/**
echo DATA_DIR;
echo "<br>";
echo DATA_URL;
echo "<br>";
echo ROOT_URL;
echo "<br>";
echo ROOT_DIR;
echo "<br>";
**/
echo $program_execute_memory;
echo "<br>";
echo $program_execute_time;
